package team.scau.laboratory_repair.web.sys;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import team.scau.laboratory_repair.common.constant.ConstantWebContext;
import team.scau.laboratory_repair.modules.po.Perm;
import team.scau.laboratory_repair.modules.po.User;
import team.scau.laboratory_repair.service.PermService;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 30254
 * creadtedate:2018/8/18
 */
@Controller
@RequestMapping("/pc")
public class MainController {

    @Autowired
    private HttpSession session;
    @Autowired
    private PermService permService;

    @GetMapping(value = "/main")
    public String madin(Model model){
        // 加载用户菜单
        User user = (User) session.getAttribute(ConstantWebContext.REQUEST_CUSER);
        List<Perm> menuList = permService.menu(user);
        model.addAttribute("menuList", menuList);
        return "/pc/main";
    }

    @GetMapping(value = "/index", produces = "text/html;charset=utf-8")
    public String index() throws Exception {
        return "/pc/index";
    }
}
